package com.cvte.shop.JobHandler;

import com.ctrip.framework.apollo.Config;
import com.ctrip.framework.apollo.ConfigService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.handler.annotation.JobHander;
import com.xxl.job.core.log.XxlJobLogger;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @author DaiShubo
 * @version 1.0
 * @description 调度中心测试
 * @createTime 2020/8/3 9:51 上午
 * @since 1.7
 **/

@JobHander(value="csbJobHandler")
@Service
public class DemoJobHandler extends IJobHandler {
    @Override
    public ReturnT<String> execute(Map<String, Object> map) throws Exception {

//        XxlJobLogger.log("###################CSB-JOB, Hello World Start.######################");
//        for (Map.Entry<String, Object> entry : map.entrySet()) {
//            XxlJobLogger.log("key = " + entry.getKey() + ", value = " + entry.getValue());
//        }
//        XxlJobLogger.log("###################CSB-JOB, Hello World End.######################");

        Config config = ConfigService.getConfig("application-demo");

        String someKey = "spring-prefix";
        String someDefaultValue = "/demo/test";
        XxlJobLogger.log("读取spring-prefix的值为："+config.getProperty(someKey, someDefaultValue));

        return ReturnT.SUCCESS;
    }
}
